package com.ruoyi.whzj.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.whzj.mapper.WhBalancerecordMapper;
import com.ruoyi.whzj.domain.WhBalancerecord;
import com.ruoyi.whzj.service.IWhBalancerecordService;
import com.ruoyi.common.core.text.Convert;

/**
 * 余额变动Service业务层处理
 * 
 * @author ruoyi
 * @date 2020-10-21
 */
@Service
public class WhBalancerecordServiceImpl implements IWhBalancerecordService 
{
    @Autowired
    private WhBalancerecordMapper whBalancerecordMapper;

    /**
     * 查询余额变动
     * 
     * @param id 余额变动ID
     * @return 余额变动
     */
    @Override
    public WhBalancerecord selectWhBalancerecordById(String id)
    {
        return whBalancerecordMapper.selectWhBalancerecordById(id);
    }

    @Override
    public float getSumMoney(String dateStr) {
        return whBalancerecordMapper.getSumMoney(dateStr);
    }

    /**
     * 查询余额变动列表
     * 
     * @param whBalancerecord 余额变动
     * @return 余额变动
     */
    @Override
    public List<WhBalancerecord> selectWhBalancerecordList(WhBalancerecord whBalancerecord)
    {
        return whBalancerecordMapper.selectWhBalancerecordList(whBalancerecord);
    }

    public List<WhBalancerecord> selectWhBalancerecordListByUserId(WhBalancerecord whBalancerecord){
        return whBalancerecordMapper.selectWhBalancerecordListByUserId(whBalancerecord);
    }

    @Override
    public List<WhBalancerecord> selectSharerecordList(WhBalancerecord whBalancerecord) {
        return whBalancerecordMapper.selectSharerecordList(whBalancerecord);
    }

    @Override
    public Map<String, Object> getNextMoney(String userId){
        return whBalancerecordMapper.getNextMoney(userId);
    }
    /**
     * 新增余额变动
     * 
     * @param whBalancerecord 余额变动
     * @return 结果
     */
    @Override
    public int insertWhBalancerecord(WhBalancerecord whBalancerecord)
    {
        whBalancerecord.setId(IdWorker.getId());
        whBalancerecord.setCreateTime(DateUtils.getNowDate());
        return whBalancerecordMapper.insertWhBalancerecord(whBalancerecord);
    }

    /**
     * 修改余额变动
     * 
     * @param whBalancerecord 余额变动
     * @return 结果
     */
    @Override
    public int updateWhBalancerecord(WhBalancerecord whBalancerecord)
    {
        return whBalancerecordMapper.updateWhBalancerecord(whBalancerecord);
    }

    /**
     * 删除余额变动对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWhBalancerecordByIds(String ids)
    {
        return whBalancerecordMapper.deleteWhBalancerecordByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除余额变动信息
     * 
     * @param id 余额变动ID
     * @return 结果
     */
    @Override
    public int deleteWhBalancerecordById(String id)
    {
        return whBalancerecordMapper.deleteWhBalancerecordById(id);
    }
}
